// index.js
import profile from '../../profile.js'

const app = getApp()

Page({
  data: {
    lang: app.globalData.language,
    index: profile.index,

    scrollTop: '',

    indexLinks: profile.index.indexLinks
  },

  navTap(e) {
    let id = e.currentTarget.id, list = this.data.indexLinks;
    console.log(id);
    for (let i=0;i<list.length;i++) {
      if(id == list[i].id) {
        list[i].show = true
      }else{
        list[i].show = false
      }
    }
    this.setData({
      indexLinks: list
    })
  },

  backTopTap(e) {
    this.setData({
      scrollTop: '0'
    })
  },

  languageTap(e) {
    let lang = this.data.lang;
    if (app.globalData.language == 'cn'){
      lang = 'en';
    }else{
      lang = 'cn';
    }
    app.globalData.language = lang;
    this.setData({
      lang
    })
  },
})
